<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="Admin/webroot/css/style.css"/>
<title>添加产品</title>
</head>
<script type="text/javascript" src="Admin/webroot/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="Admin/webroot/js/global.js"></script>
<script type="text/javascript" src="Admin/webroot/js/input.js"></script>
<script type="text/javascript" src="Admin/webroot/js/editor/kindeditor.js"></script>
<script type="text/javascript" src="Admin/webroot/js/kindeditor_upload.js">
</script>
<!--[if IE ]>
<style>.localUpload{ display:none}.msg-s .ke-inline-block{ display:block} </style>
<![endif]-->
<body >
<!--[if lte IE 6]>
<script src="js/DD_belatedPNG_0.0.8a.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
	DD_belatedPNG.fix('.pngfix');
</script>
<![endif]-->
<div class="rightbox">
    	<div class="rightbox-col" id="rightbox">
        	<div class="main">
                <div class="title">
                   
                   当前位置<a href="#">>首页</a>><a href="#">内容管理</a>>产品中心
                </div>
                <div class="bd">
                	<div class="height_20"></div>
                    <div class="add-pro-info">
                       
                            <div class="pro-info">
                            	<div id="pro">
                                    <div class="left-table"><span class="red">*</span>产品名称：</div>
                                    <div class="right-table"><input type="text" name="title" placeholder="请填写产品名称" value="{$pro.title}" /></div>
                                    <div class="msg"></div>
                                    <div class="height_10"></div>
                                    <div class="left-table">产品型号：</div>
                                    <div class="right-table"><input type="text" name="model" value="{$pro.model}"/></div>
                                    <div class="msg">
                                        
                                    </div>
                                    <div class="height_10"></div>
                                    <div class="left-table">产品尺寸：</div>
                                    <div class="right-table"><input type="text" name="size" value="{$pro.size}"/></div>
                                    <div class="msg" style="padding-left:6px;">
                                        *
                                    </div>
                                    <div class="height_10"></div>
                                    {if $pro_img}
                                    {foreach from=$pro_img item=img name=img}
                                    <div class="pro-floor">
                                    <div class="left-table">产品图片：</div>
                                    <div class="right-table"><input class="pro_img" type="text" data-imgid='{$img.id}' name="pro_url[]" id="img_url_{$smarty.foreach.img.iteration}" value="{$img.original_pic}"/></div>
                                    <div class="msg-s">
                                  <a href="javascript:;" class="localUpload f_l" onclick="$(this).next().next().next().children('form').children('.ke-upload-file').click()">本地上传</a>
                                        <a href="javascript::" class="add-pic " onclick="addNewPic()">添加新图片</a> <a href="javascript::" class="del_btn f_l del_pro">X</a>
                                       
                                         <input id="uploadButton_{$smarty.foreach.img.iteration}" return_url="img_url_{$smarty.foreach.img.iteration}" type="button" value="submit" />
                                        
  </div>
    <div class="height_10"></div>
    </div>
                                    {/foreach}
                                    {else}
                                     <div class="pro-floor">
                                     <div class="left-table">产品图片：</div>
                                    <div class="right-table"><input class="pro_img" type="text" name="pro_url[]" data-imgid="new_1" id="img_url_1" value="" id="uploadf1"/></div>
                                    <div class="msg-s">
                                        <a href="javascript:;" class="localUpload f_l" onclick="$(this).next().next().children('form').children('.ke-upload-file').click()">本地上传</a>
                                        <a href="javascript::" class="add-pic " onclick="addNewPic()">添加新图片</a>
                                       
                                         <input id="uploadButton_1" return_url="img_url_1" type="button" value="submit" />
                                  
                                    </div>
                                     <div class="height_10"></div>
                                     </div>
                                    {/if}
                                   
                                </div>
                            </div>
                            <div class="height_20"></div>
                            <div class="pro">
                            	<div class="hd next-hd">
                                	<span class="focus"></span>
                                    SEO信息
                                    <div class="clear"></div>
                                </div>
                                <div class="bd" style="display:block">
                                	<table cellpadding="0" cellspacing="0" border="0" width="100%">
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">页面标题</td>
                                        <td width="434px"><input type="text" name="page_title" value="{$pro.page_title}"/></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">页面关键词：</td>
                                        <td width="434px"><textarea class="keywords" name="keywords">{$pro.keywords}</textarea></td>
                                        <td valign="top"></td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">页面摘要：</td>
                                        <td width="434px"><textarea class="keywords" name="abstract">{$pro.abstract}</textarea></td>
                                        <td></td>
                                    </tr>
                                    
                                </table>
                                </div>
                            </div>
                            <div class="height_20"></div>
                            <div class="pro">
                            	<div class="hd next-hd">
                                	<span class="icon-c" ></span>
                                    扩展信息
                                     <div class="clear"></div>
                                </div>
                                <div class="bd next-hd">
                                	<table cellpadding="0" cellspacing="0" border="0" width="100%">
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">缩略图</td>
                                        <td width="434px"><input id="img_url_" class="pro_img" type="text" disabled="disabled" name="thumb_url" value="{$pro.thumb}"/></td>
                                        <td>
                                        	           <div class="msg-s">	<a href="javascript:;"   class="localUpload" onclick="$(this).next().children('form').children('.ke-upload-file').click()">本地上传</a>
                   <input id="uploadButton_" return_url='img_url_' type="button" value="submit" />   
                 
                  </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">点击次数：</td>
                                        <td width="434px"><input type="text" name="hits" value="{$pro.hits}"/></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">是否推送：</td>
                                        <td width="434px"><input type="text" name="is_push" value="{$pro.is_push}"/></td>
                                        <td>次</td>
                                    </tr>
                                    <tr>
                                        <td width="85px" style="padding-right:7px" align="right">是否显示：</td>
                                        <td width="434px">
                                        	<div class="s-radio-x">
                                            <a href="javascript:;" data-checked="1" {if $pro.is_show==1}class="focus"{/if}></a> 是 &nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="javascript:;" data-checked="0" {if $pro.is_show==0}class="focus"{/if}></a> 否
                                            <input type="hidden" name="is_show" class="show" value="{$pro.is_show}"/>
                                            </div>
                                            
                                        </td>
                                        <td></td>
                                    </tr>
                                    
                                </table>
                                </div>
                            </div>
                            <div class="height_20"></div>
                            <div class="pro">
                            	<div class="hd next-hd">
                                	<span class="icon-c" ></span>
                                    产品介绍
                                     <div class="clear"></div>
                                </div>
                                <div class="bd">
                                	<textarea class="pro-view" id="pro-view" name="content" style="width:680px; height:348px;">{$pro.content}</textarea>
                                </div>
                            </div>
                            <div class="height_20"></div>  <input type="hidden" name="cat_id" value="{$cat_id}"/>
                            <input type="hidden" name="id" value="{$id}"/>
                            <input type="submit" class="pro-add-sub submit_btn" value="保存"/>
                            <div class="height_24"></div>
                       
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>

<script type="text/javascript">
    $(function(){
		$('.del_pro').live('click',function(){
			$(this).parent().parent().remove();
			});
		hungry_uploadimg();	
		
		$('.pro-add-sub').click(function(){
			var action = '{$action}';
			var cat_id=($('input[name=cat_id]').val());
			var id=($('input[name=id]').val());
			var title=($('input[name=title]').val());
			var abstract=($('textarea[name=abstract]').val());
			var keywords=($('textarea[name=keywords]').val());
			var model=($('input[name=model]').val());
			var size=($('input[name=size]').val());
			var hits=($('input[name=hits]').val());
			var is_push=($('input[name=is_push]').val());
			{literal}
			var img_array='{';
			{/literal}
			var pro_url=$('.main').find('input[name="pro_url[]"]')
			pro_url.each(function()
			{
				
				img_array+='"'+$(this).attr('data-imgid')+'":"'+$(this).val()+'",';
			}
			);
			img_array=img_array.substr(0,img_array.length-1)+'}';
			var content=$('textarea[name=content]').val();
			
			var is_show=($('input[name=is_show]').val());
			var page_title=($('input[name=page_title]').val());
			var thumb=($('input[name=thumb_url]').val());
			$.post('index.php?g=admin&m=pro&a='+action,{ id:id,content:content,cat_id:cat_id,title:title,abstract:abstract,model:model,keywords:keywords,size:size,img_array:img_array,is_push:is_push,hits:hits,page_title:page_title,is_show:is_show,thumb:thumb},function(result){
				
			showMsg(result.content,result.url);
				},'json');
			})
		
		});
	
</script>

 <script>
 function addNewPic(){
	 var i=1;
  $(' input[name="pro_url[]"]').each(function(index, element) {
    i++;
	
        });
		
var html='  <div class="pro-floor"><div class="left-table">产品图片：</div>';
	html+='<div class="right-table"><input data-imgid=new_'+i+'  type="text" name="pro_url[]" value=""  id="img_url_'+i+'"/></div>';
	html+='<div class="msg-s">';
	html+='<a href="javascript:;" class="localUpload f_l" onclick="$(this).next().next().next().children(\'form\').children(\'.ke-upload-file\').click()">本地上传</a>';
	html+='<a href="javascript:;" class="add-pic" onclick="addNewPic()">添加新图片</a>';
	html+='<a href="javascript:;" class="del_btn f_l del_pro">X</a>';
	html+='<input id="uploadButton_'+i+'" type="button" return_url="img_url_'+i+'" value="submit" />';
	html+='</div>';
		
	html+='<div class="height_10"></div>';
	html+='</div>';
	$(html).appendTo("#pro");
	hungry_uploadimg();
	 }
 </script>
<script type="text/javascript">
$(".next-hd").click(function(){
	var html=$(this).find("span").attr("class");
	if(html=='icon-c'){
		$(this).next(".bd").show();
		$(this).find("span").attr('class','focus');
		
	}else{
		$(this).next(".bd").hide();
		$(this).find("span").attr('class','icon-c');
	}
})

</script>

</body>
</html>
